//
//  UserInfo.m
//  CarCare
//
//  Created by ileo on 14-8-11.
//  Copyright (c) 2014年 baozun. All rights reserved.
//

#import "AIUserInfo.h"
#import "NetDealMgr.h"
#import "EncryptMgr.h"

typedef NS_OPTIONS(NSUInteger, Device_Adaption){
    Device_Adaption_None    = 0,
    Device_Adaption_Voltage = 1 << 0,
    Device_Adaption_Mileage = 1 << 1,
    Device_Adaption_Oil     = 1 << 2,
};

@implementation AIUserInfo

IMP_SINGLETON

-(NSString *)iczkey{
    return [EncryptMgr encryptWithString:[EncryptMgr sortAndSpliceWithParams:@{@"icz_uid":@(self.userID)}]];
}

-(NSString *)showName{
    return self.userName;
}

-(NSString *)showImageURL{
    return self.headImageURL;
}

-(NSString *)carInfoName{
    return [NSString stringWithFormat:@"%@ %@",self.carModel,self.carStyle];
}

#pragma mark - 
-(DateModel *)bindingDay{
    DateModel *date = [[DateModel alloc] init];
    date.year = [[self.deviceBindingTime substringToIndex:4] integerValue];
    date.month = [[self.deviceBindingTime substringWithRange:NSMakeRange(5, 7)] integerValue];
    date.day = [[self.deviceBindingTime substringWithRange:NSMakeRange(8, 10)] integerValue];
    return date;
}

#pragma mark - 适配
-(void)setFitFlag:(NSInteger)fitFlag{
    _fitFlag = fitFlag;

    self.adaption_Mileage = (Device_Adaption_Mileage + Device_Adaption_Oil + Device_Adaption_Voltage == fitFlag)
                            || (Device_Adaption_Mileage == fitFlag)
                            || (Device_Adaption_Mileage + Device_Adaption_Oil == fitFlag)
                            || (Device_Adaption_Mileage + Device_Adaption_Voltage == fitFlag);
    self.adaption_Oil = (Device_Adaption_Mileage + Device_Adaption_Oil + Device_Adaption_Voltage == fitFlag)
                        || (Device_Adaption_Oil == fitFlag)
                        || (Device_Adaption_Mileage + Device_Adaption_Oil == fitFlag)
                        || (Device_Adaption_Oil + Device_Adaption_Voltage == fitFlag);
    self.adaption_Voltage = (Device_Adaption_Mileage + Device_Adaption_Oil + Device_Adaption_Voltage == fitFlag)
                            || (Device_Adaption_Voltage == fitFlag)
                            || (Device_Adaption_Voltage + Device_Adaption_Oil == fitFlag)
                            || (Device_Adaption_Mileage + Device_Adaption_Voltage == fitFlag);

}

@end
